# coding: utf-8
# author: t_wolf

from web_utils import *


class EasyWebEntry:
    def __init__(self):
        pass

    def GET(self):
        return web.config.render.base(
            "Welcome to EasyWeb!",
            u"""<span style="font-size: 10em;">EasyWeb</span><br/>The extremely simple Web Container."""
        )


class ExpiredEasyWeb:
    def __init__(self):
        pass

    def GET(self):
        print web.ctx.env

        # web.header(
        #     'Refresh',
        #     '%d;url="%s"' % (
        #         CONFIGS.APP.redirect_time,
        #         web.ctx.env.get('HTTP_REFERER', '/')
        #     )
        # )

        return web.config.render.base(
            "Session Expired",
            u"""<span style="font-size: 14em;">会话过期</span><br/>您的会话已过期。"""
            # %d秒后跳转回上一页面。""" % CONFIGS.APP.redirect_time
        )

    def POST(self):
        raise web.seeother('/expired', True)


def not_found_4_easy_web():
    path = web.ctx.homepath + web.ctx.path
    return web.notfound(
        web.config.render.base(
            "404 Not Found",
            u"""<span style="font-size: 24em;">404</span>
            <br/>您访问的地址[<span style="color: red; font-size: 18px;">%s</span>]不存在.<br/>""" % path
        )
    )
